#pragma once

#include "simmodel.h"
#include "ui_scriptEditor.h"
#include <QtGui/QMainWindow>
#include <QtGui/QWidget>
#include <QDialog>
#include <QAbstractTableModel>
#include <QList>
#include <QStringList>
#include <QItemDelegate>
#include <QTimeEdit>
#include <QLineEdit>
#include <QSpinBox>
#include <QComboBox>
#include <vector>
#include <map>
#include <qwt_plot_canvas.h>
#include <qwt_legend.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_curve.h>
#include <qwt_symbol.h>
using namespace std;

/*
struct scriptElement{
		double time;
		string variable;
		double value;
		string unit;
	};*/

class scriptEditor : public QDialog
{
	Q_OBJECT
	
private:
	Ui::scriptEditorDialog ui;
	pair<vector<string>, vector<string>> SetOfProperties;
	pair<vector<vector<string>>, vector<vector<double>>> VectorUnitAndCoeff;
	vector<string> getSetOfUnits(string u);
	double getCoeff(string u);
	void addRow(double time = 0, string variable = "", double value = 0, string unit = "");
	
	void initGraph();
	void createGraph();
	string Parameter;
	QwtLegend *leg;
	QwtPlotGrid *grid;
	QwtPlotCurve *curve;
public:
	scriptEditor(QWidget* pwgt = 0);	
	~scriptEditor();
	void setData(pair<vector<string>, vector<string>> properties, pair<vector<vector<string>>, vector<vector<double>>> unitAndCoeff,
		map<string, vector<simModel::scriptElement>> script, string parameters = "all");
	map<string, vector<simModel::scriptElement>> getScript();
	vector<simModel::scriptElement> getScriptOne();
private slots:
	void on_btnAdd_clicked();
	void on_btnDelete_clicked();
	void on_btnAccept_clicked();
	void on_btnReject_clicked();
	void on_btnRefresh_clicked();
	void comboBoxIndexChanged(const int &row);
	void table_rowCountChanged() ;
};